import React from "react";
import { message } from 'antd';
import axios from "axios";
import './Login.css'
const Content1 = (props) => {
    const onFinish = () => {
        var name = document.getElementById('name').value;
        var pass = document.getElementById('pass').value;
        const usermessage = { "admins_name": name, "admins_password": pass }
        axios.post('http://192.168.72.166:8080/api/adminsSignIn', usermessage)
            .then(res => {
                const data = res.data.data
                if (data.admins_name) {
                    props.history.replace('/back');
                    message.success('登入成功!');
                } else {
                    message.error('用户名或密码错误!');
                }
            })
    }
    return (
        <div className="login">
            <div className="login_1">
                <img src={require('../images/logo.png')} />
                <h2>欢迎登入格物衍艺后台管理系统！</h2>
                <div>账号:<input placeholder="请输入账号" id="name" name="name" /></div>
                <div>密码:<input placeholder="请输入密码" id="pass" name="pass" type="password" /></div>
                <button onClick={onFinish}>登入</button>
            </div>
        </div>
    )
}

export default Content1;